<template>
  <view class="index tn-safe-area-inset-bottom">
    <tn-navbar
      fixed
      z-index="1"
      :bottom-shadow="false"
      :is-back="false"
      bg-color="tn-bg-main"
    >
      <view class="custom-nav">
        <view
          class="custom-nav-back flex-size-block animation tn-flex-2 tn-radius tn-shadow-blur"
        >
          <view class="custom-nav-back-content"> 雅尚轩 </view>
        </view>
        <view
          class="custom-nav-search flex-size-block animation--right tn-flex-6 tn-radius tn-shadow-blur"
        >
          <view class="custom-nav-search-content tn-flex-row">
            <view class="custom-nav-search-content-icon">
              <tn-icon class="tn-color-main" icon="search"></tn-icon>
            </view>
            <view class="tn-flex-6">
              <tn-input
                height="100%"
                placeholder="请输入要搜索的内容"
              ></tn-input>
            </view>
            <view class="tn-flex-2 search-button tn-bg-main">
              <tn-button class="searchButton" @click="search">搜索</tn-button>
            </view>
          </view>
        </view>
      </view>
    </tn-navbar>

    <view class="home-swiper">
      <!-- 轮播 -->
      <tn-swiper
        :data="swiperData"
        indicator-mode="round"
        height="355"
        radius="0"
        @click="swiperClick"
      ></tn-swiper>
    </view>

    <view class="home-service tn-flex-row">
      <view class="home-service-item tn-flex-1"
        ><TnIcon class="icon tn-color-main" icon="vip"></TnIcon>正品保证</view
      >
      <view class="home-service-item tn-flex-1"
        ><TnIcon class="icon tn-color-main" icon="service"></TnIcon
        >7天无理由退货</view
      >
      <view class="home-service-item tn-flex-1"
        ><TnIcon class="icon tn-color-main" icon="money"></TnIcon
        >48小时快速退款</view
      >
    </view>
    <!-- 导航 -->
    <view class="home-nav">
      <view class="home-nav-content tn-flex-row">
        <view
          v-for="nav in navData"
          class="home-nav-content-item tn-flex-1 tn-flex-column"
        >
          <view class="home-nav-content-item-img">
            <img :src="nav.img" />
          </view>
          <view class="home-nav-content-item-text">{{ nav.text }}</view>
        </view>
      </view>
    </view>

    <!-- vip -->
    <view class="home-vip">
      <view class="home-vip-content tn-flex-row">
        <view class="home-vip-content-left tn-flex-4 tn-radius tn-flex-column">
          <view class="content-text"> 轻奢大牌 </view>
          <view class="content-img">
            <img src="@/static/images/demo/vip/qinshe.png" />
          </view>
        </view>
        <view class="tn-flex-5 tn-flex-column">
          <view class="home-vip-content-right1 tn-radius tn-flex-row">
            <view class="content-text tn-flex-3 tn-flex-column"
              >福利社<span>今日特价</span></view
            >
            <view class="content-img tn-flex-4">
              <img src="@/static/images/demo/vip/fulishe.png" />
            </view>
          </view>
          <view class="home-vip-content-right2 tn-radius tn-flex-row">
            <view class="content-text tn-flex-3 tn-flex-column">
              新品首发 <span>爆款好物</span></view
            >
            <view class="content-img tn-flex-4">
              <img src="@/static/images/demo/vip/xinpin.png" />
            </view>
          </view>
        </view>
      </view>
    </view>

    <!-- 热门推荐横幅 -->
    <view class="home-hot tn-flex-column">
      <view class="home-hot-content">
        <img src="@/static/images/demo/hot/hot.jpg" />
      </view>
    </view>

    <!-- 商品列表 -->
    <view class="home-goods">
      <view class="home-goods-item tn-flex-row">
        <!-- 商品图片 -->
        <view class="home-goods-item-img">
          <img src="@/static/images/demo/goods/goods-1.jpg" />
        </view>
        <!-- 商品信息 -->
        <view class="home-goods-item-content tn-flex-column">
          <!-- 【送礼推荐】Louis Vuitton 路易威登 Trainer 低帮休闲板鞋 男女同款 蓝白 -->
          <view class="home-goods-item-content-title tn-flex-2">
            <div class="box">
              <div class="wrap">
                路易威登 Trainer 低帮休闲板鞋 男女同款 蓝白
              </div>
            </div>
          </view>
          <view class="home-goods-item-content-tags tn-flex-1">
            <!-- <div class="tag">优选好物</div> -->
            <div class="tag">新品上市</div>
          </view>
          <view class="home-goods-item-content-tool tn-flex-2 tn-flex-row">
            <!-- <div class="tag">尊享成本价</div> -->
            <div class="price tn-flex-1"><span>￥</span>8639.00</div>
            <div class="buy tn-flex-1">
              <div class="buy-button">马上买</div>
            </div>
          </view>
        </view>
      </view>

      <view class="home-goods-item tn-flex-row">
        <!-- 商品图片 -->
        <view class="home-goods-item-img">
          <img src="@/static/images/demo/goods/goods-2.jpg" />
        </view>
        <!-- 商品信息 -->
        <view class="home-goods-item-content tn-flex-column">
          <!-- 【送礼推荐】Louis Vuitton 路易威登 Trainer 低帮休闲板鞋 男女同款 蓝白 -->
          <view class="home-goods-item-content-title tn-flex-2">
            <div class="box">
              <div class="wrap">路易威登 Metis系列 拼色老花翻盖涂层</div>
            </div>
          </view>
          <view class="home-goods-item-content-tags tn-flex-1">
            <div class="tag">优选好物</div>
            <!-- <div class="tag">新品上市</div> -->
          </view>
          <view class="home-goods-item-content-tool tn-flex-2 tn-flex-row">
            <!-- <div class="tag">尊享成本价</div> -->
            <div class="price tn-flex-1"><span>￥</span>18639.00</div>
            <div class="buy tn-flex-1">
              <div class="buy-button">马上买</div>
            </div>
          </view>
        </view>
      </view>

      <view class="home-goods-item tn-flex-row">
        <!-- 商品图片 -->
        <view class="home-goods-item-img">
          <img src="@/static/images/demo/goods/goods-1.jpg" />
        </view>
        <!-- 商品信息 -->
        <view class="home-goods-item-content tn-flex-column">
          <!-- 【送礼推荐】Louis Vuitton 路易威登 Trainer 低帮休闲板鞋 男女同款 蓝白 -->
          <view class="home-goods-item-content-title tn-flex-2">
            <div class="box">
              <div class="wrap">
                Louis Vuitton 路易威登 Trainer 低帮休闲板鞋 男女同款 蓝白
              </div>
            </div>
          </view>
          <view class="home-goods-item-content-tags tn-flex-1">
            <div class="tag">奢品大牌</div>
            <!-- <div class="tag">新品上市</div> -->
          </view>
          <view class="home-goods-item-content-tool tn-flex-2 tn-flex-row">
            <!-- <div class="tag">尊享成本价</div> -->
            <div class="price tn-flex-1"><span>￥</span>8639.00</div>
            <div class="buy tn-flex-1">
              <div class="buy-button">马上买</div>
            </div>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { CSSProperties, ref } from "vue";
import TnNavbar from "@/tuniao-ui/components/tn-navbar/src/Navbar.vue";
import TnIcon from "@/tuniao-ui/components/tn-icon/src/Icon.vue";
import TnInput from "@/tuniao-ui/components/tn-input/src/Input.vue";
import TnSwiper from "@/tuniao-ui/components/tn-swiper/src/Swiper.vue";
import TnButton from "@/tuniao-ui/components/tn-button/src/Button.vue";
import { SwiperData } from "@/tuniao-ui/types";

import swiper1Url from "@/static/images/demo/swiper/1.jpeg";
import swiper2Url from "@/static/images/demo/swiper/2.jpeg";
import navImg1 from "@/static/images/demo/nav/img-1.jpg";
import navImg2 from "@/static/images/demo/nav/img-2.jpg";
import navImg3 from "@/static/images/demo/nav/img-3.jpg";
import navImg5 from "@/static/images/demo/nav/img-5.png";

// import { getHomeIndex } from "@/api/test";

// get();

// async function get() {
//   const data = await getHomeIndex({});

//   console.log(data);
// }

// 轮播图数据
const swiperData: SwiperData[] = [
  { image: swiper1Url },
  { image: swiper2Url },
];

const navData = ref([
  {
    text: "人气奢包",
    img: navImg1,
  },
  {
    text: "潮奢名表",
    img: navImg2,
  },
  {
    text: "首饰好物",
    img: navImg3,
  },
  {
    text: "本地生活",
    img: navImg1,
  },
  {
    text: "每日抢购",
    img: navImg5,
  },
]);

function swiperClick(index: any) {
  console.log(index);
}
function search() {
  console.log("search");
}
</script>

<style lang="scss" scoped>
.index {
  margin-bottom: 200rpx;
}
.custom-nav {
  height: 100%;
  width: 100%;
  display: flex;
  &-back {
    height: 100%;
    width: 30%;
    color: #fff;
    &-content {
      width: 100%;
      text-align: center;
      line-height: 90rpx;
      font-size: 35rpx;
      font-weight: bold;
    }
  }

  &-search {
    height: 100%;
    width: 70%;
    &-content {
      width: 100%;
      margin: 5rpx 0;
      border-radius: 50rpx;
      background-color: #fff;
      border: 2rpx solid #fff;
      &-icon {
        width: 60rpx;
        height: 100%;
        //background-color: #000;
        font-size: 1.5rem;
        padding-left: 10rpx;
        display: flex;
        .tn-icon {
          justify-content: center;
          align-items: center;
        }
      }
      .search-button {
        line-height: 90rpx;
        border-radius: 50rpx;
        font-size: 30rpx;
        justify-content: center;
        .searchButton {
          border-radius: 50rpx;
        }
      }
    }
  }
}

.home-swiper {
  width: 100%;
  height: 355rpx;
}

.home-service {
  width: 100%;
  height: 60rpx;
  font-size: 18rpx;
  margin-top: 10rpx;
  &-item {
    justify-content: center;
    align-items: center;
    color: #333;
  }
  .icon {
    font-size: 35rpx;
    margin-right: 10rpx;
  }
}

.home-nav {
  width: 100%;
  margin-top: 0rpx;
  padding: 0 20rpx;
  //   padding-bottom: 20rpx;
  &-content {
    background-color: #fff;
    border-radius: 20rpx;
    padding-bottom: 20rpx;
    &-item {
      justify-content: center;
      align-items: center;
      color: #333;
      font-size: 20rpx;
      &-img {
        width: 60%;
        overflow: hidden;
        margin-bottom: 5rpx;
        img {
          width: 100%;
          height: 100%;
        }
      }
      &-text {
        width: 100%;
        text-align: center;
        font-weight: bold;
      }
    }
  }
}
.home-vip {
  width: 100%;
  height: 350rpx;
  margin-top: 20rpx;
  padding: 0 20rpx;
  color: #333;
  &-content {
    width: 100%;
    height: 100%;

    &-left {
      background-color: #f9e9cf;
      margin-right: 10rpx;
      .content-text {
        height: 15%;
        font-size: 35rpx;
        text-align: center;
        margin-top: 40rpx;
        font-weight: 500;
      }
      .content-img {
        width: 100%;
        height: 65%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        img {
          width: 100%;
        }
      }
    }

    &-right1,
    &-right2 {
      height: 50%;
      .content-text {
        font-size: 35rpx;
        text-align: center;
        font-weight: 500;
        margin-top: 20rpx;
        span {
          font-size: 20rpx;
          color: #999;
        }
      }
      .content-img {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        img {
          width: 100%;
        }
      }
    }
    &-right1 {
      background-color: #fbe2d3;
      margin-bottom: 10rpx;
    }
    &-right2 {
      background-color: #ffecc2;
      .content-text {
        span {
          background-color: #ccc;
          color: #fff;
          border-radius: 5rpx;
          margin: 0 30rpx;
        }
      }
    }
  }
}

.home-hot {
  margin-top: 30rpx;
  &-content {
    img {
      width: 100%;
    }
  }
}

.home-goods {
  margin-top: 20rpx;
  padding: 0 20rpx;
  img {
    width: 100%;
  }
  &-item {
    height: 270rpx;
    display: flex;
    border-radius: 15rpx;
    overflow: hidden;
    background-color: #fff;
    margin-bottom: 20rpx;
    &-img {
      width: 270rpx;
      img {
        width: 100%;
        height: 100%;
      }
    }
    &-content {
      height: 100%;
      flex: 1;
      padding: 20rpx;

      &-title,
      &-tags,
      &-price,
      &-tool {
        box-sizing: border-box;
        display: flex;
        align-items: center;
      }
      &-title {
        .box {
          display: table;
          .wrap {
            letter-spacing: 0;
            overflow: hidden;
            display: -webkit-box;
            text-overflow: ellipsis;
            -webkit-line-clamp: 1;
            -webkit-box-orient: vertical;
            font-size: 30rpx;
            font-weight: 600;
          }
        }
      }
      &-tags {
        .tag {
          border: 1px solid #b88230;
          border-radius: 5rpx;
          color: #b88230;
          padding: 5rpx 10rpx;
          font-size: 18rpx;
          margin-right: 20rpx;
        }
      }
      &-price {
        color: #f00;
        font-size: 38rpx;
        align-items: flex-end;
        span {
          font-size: 18rpx;
        }
      }

      &-tool {
        align-items: flex-end;
        .tag {
          background-color: #333;
          color: #d5d072;
          padding: 5rpx 10rpx;
          font-size: 18rpx;
          margin-right: 10rpx;
          border-radius: 5rpx;
        }

        .price {
          color: #f00;
          font-size: 38rpx;
          align-items: baseline;
          span {
            font-size: 18rpx;
          }
        }
        .buy {
          justify-content: flex-end;
          .buy-button {
            background-color: #333;
            color: #d5d072;
            padding: 10rpx 20rpx;
            // margin-left: 10rpx;
          }
        }
      }
    }
  }
}
</style>
